/**
 * 
 */
package com.corestructures.learn.java.algos.sorting;

import java.util.ArrayList;

/**
 * @author nagrawal2
 * 
 */
public class InsertionSort {
	public static void sort(int[] intArray) {
		int key = 0;
		int outerCounter = 0;
		int currValue = 0;
		while (++outerCounter <= intArray.length - 1) {
			key = intArray[outerCounter];
			if (key > intArray[outerCounter - 1])
				continue;
			else {
				int innerCounter = outerCounter;
				while (innerCounter > 0 && key < intArray[--innerCounter]) {
					intArray[innerCounter + 1] = intArray[innerCounter];
				}
				intArray[innerCounter] = key;

			}

			for (int count : intArray)
				System.out.println(count);

		}

		return;
	}

	/*
	 * public static void main(String[] args) { int[] intArray = { 3, 15, 1 };
	 * InsertionSort.sort(intArray); for (int count : intArray)
	 * System.out.println(count); }
	 */

}
